package com.ming.config;

import com.ming.constant.QueueConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:何元才
 * @Desc:
 * @data:2021-04-07 16:32
 */
@Configuration
public class MemberMQConfig {

    @Bean
    public Queue phoneQueue(){
        return new Queue(QueueConstant.PHONE_SMS_QUEUE);
    }

    @Bean
    public DirectExchange phoneEx(){
        return new DirectExchange(QueueConstant.PHONE_SMS_EX);
    }

    @Bean
    public Binding phoneBind(){
        return BindingBuilder.bind(phoneQueue()).to(phoneEx()).with(QueueConstant.PHONE_SMS_KEY);
    }

    @Bean
    public Queue wxQueue() {
        return new Queue(QueueConstant.WX_SMS_QUEUE);
    }

    @Bean
    public DirectExchange wxEx() {
        return new DirectExchange(QueueConstant.WX_SMS_EX);
    }

    @Bean
    public Binding wxBind() {
        return BindingBuilder.bind(wxQueue()).to(wxEx()).with(QueueConstant.WX_SMS_KEY);
    }
}
